package de.mizi.controller;

import java.util.LinkedList;
import java.util.List;

/**
 * An observable GameModel.
 * @author mizi
 *
 */
public class GameModel {
	protected List<GameListener> listeners;
	
	/**
	 * Constructs a new GameModel object with an empty list of listeners.
	 */
	public GameModel() {
		this.listeners = new LinkedList<GameListener>();
	}
	
	/**
	 * Adds a new listener to this GameModel object.
	 * @param listener the new listener
	 */
	public void addGameListener(GameListener listener) {
		if(!listeners.contains(listener)) {
			listeners.add(listener);
		}
	}
	
	/**
	 * Removes a listener from this GameModel object.
	 * @param listener the listener that shall be removed
	 */
	public void removeGameListener(GameListener listener) {
		if(listeners.contains(listener)) {
			listeners.remove(listener);
		}
	}
}
